<template>
    <view class="legal-risk-page">
        <!-- 页面内容 -->
        <z-paging ref="paging" 
            v-model="resData" 
            @query="queryList" 
            :show-loading-more-when-reload="true"
            :loading-more-title-custom-style="{'font-size':'22rpx'}"
            :inside-more="true"
            loading-more-loading-text="加载中~"
            loading-more-no-more-text="到底了~"
            :to-bottom-loading-more-enabled="true"
        >
            <riskItem :totalCount="totalCount" :dataForm="pageFormInfo" :resData="resData" />
        </z-paging>
    </view>
</template>

<script setup>
import { ref } from 'vue';
import { onLoad } from "@dcloudio/uni-app";
import { managerisklistApi, managelistApi, legalrisklistApi,intelproplistApi,devhislistApi } from '@/api/basicInfo';
import riskItem from './component/riskItem.vue';
// 国际分类code 转 中文
const trademark = ref({
    "1": "化学原料",
    "2": "颜料油漆",
    "3": "日化用品",
    "4": "日化用品",
    "5": "医用药品",
    "6": "金属材料",
    "7": "机械设备",
    "8": "手工器械",
    "9": "科学仪器",
    "10": "医疗器械",
    "11": "灯具空调",
    "12": "运输工具",
    "13": "军火烟火",
    "14": "珠宝钟表",
    "15": "音乐器材",
    "16": "办公用品",
    "17": "橡胶制品",
    "18": "皮革皮具",
    "19": "建筑材料",
    "20": "家具用品",
    "21": "厨房洁具",
    "22": "绳网袋篷",
    "23": "纺织纱线",
    "24": "布料床单",
    "25": "服装鞋帽",
    "26": "纽扣拉链",
    "27": "地毯席垫",
    "28": "健身器材",
    "29": "食品鱼肉",
    "30": "方便食品",
    "31": "饲料种籽",
    "32": "啤酒饮料",
    "33": "酒精饮料",
    "34": "烟草烟具",
    "35": "广告销售",
    "36": "金融物管",
    "37": "建筑修理",
    "38": "通讯服务",
    "39": "运输贮藏",
    "40": "材料加工",
    "41": "教育娱乐",
    "42": "网站服务",
    "43": "餐饮住宿",
    "44": "医疗园艺",
    "45": "社会服务"
});

// 基础信息导航
const basicInfoNav = ref([
    {
        title: "经营异常", //列入日期 列入经营异常名单原因 列入决定机关 移出日期 移出决定机关
        code: "09",
        form: [
            {
                label: "列入日期",
                key: "inDate"
            },
            {
                label: "列入经营异常名单原因",
                key: "inReason"
            },
            {
                label: "列入决定机关",
                key: "department"
            },
            {
                label: "移出日期",
                key: "outDate"
            },
            {
                label: "移出决定机关",
                key: "outDepartment"
            },
        ],
    },
    {
        title: "行政处罚", //公示时间 处罚决定时间 决定文书号 违法行为类型 行政处罚内容 决定机关
        code: "06",
        form: [
            {
                label: "公示时间",
                key: "publicDate"
            },
            {
                label: "处罚决定时间",
                key: "date"
            },
            {
                label: "决定文书号",
                key: "number"
            },
            {
                label: "违法行为类型",
                key: "illegalType"
            },
            {
                label: "行政处罚内容",
                key: "punishmentText"
            },
            {
                label: "决定机关",
                key: "department"
            },
        ]
    },
    {
        title: "环保处罚", //公示时间 处罚决定时间 决定文书号 违法行为类型 行政处罚内容 决定机关
        code: "01",
        form: [
            {
                label: "公示时间",
                key: "punishmentDate"
            },
            {
                label: "处罚决定时间",
                key: "punishmentDate"
            },
            {
                label: "决定文书号",
                key: "documentNo"
            },
            {
                label: "违法行为类型",
                key: "illegalType"
            },
            {
                label: "行政处罚内容",
                key: "punishmentResult"
            },
            {
                label: "决定机关",
                key: "punishmentDept"
            },
        ]
    },
    {
        title: "严重违法", //列入日期 列入原因 列入决定机关 移出日期 移出决定机关
        code: "09",
        form: [
            {
                label: "列入日期",
                key: "inDate"
            },
            {
                label: "列入原因",
                key: "inReason"
            },
            {
                label: "列入决定机关",
                key: "inDepartment"
            },
            {
                label: "移出日期",
                key: "outDate"
            },
            {
                label: "移出决定机关",
                key: "outDepartment"
            }
        ]
    },
    {
        title: "简易注销", //企业名称 统一社会信用代码 登记机关 公告期 异议信息 简易注销结果
        code: "08",
        form: [
            {
                label: "企业名称",
                key: "name"
            },
            {
                label: "统一社会信用代码",
                key: "creditRegNo"
            },
            {
                label: "登记机关",
                key: "department"
            },
            {
                label: "公告期",
                key: "noticePeriod"
            },
            {
                label: "异议信息",
                key: "gsScaObjections"
            },
            {
                label: "简易注销结果",
                key: "gsScaResult"
            }
        ]
    },
    {
        title: "欠税公告", //所属税务机关 发布日期 欠税税种 以前年度陈欠余额 当前新发生的欠税余额 合计欠税余额 经营地点 欠税周期
        code: "02",
        form: [
            {
                label: "所属税务机关",
                key: "pubDepartment"
            },
            {
                label: "发布日期",
                key: "pubDate"
            },
            {
                label: "欠税税种",
                key: "overdueType"
            },
            {
                label: "以前年度陈欠余额",
                key: "historyOverdueAmount"
            },
            {
                label: "当前新发生的欠税余额",
                key: "currOverdueAmount"
            },
            {
                label: "合计欠税余额",
                key: "overdueAmount"
            },
            {
                label: "经营地点",
                key: "area"
            },
            {
                label: "欠税周期",
                key: "overduePeriod"
            }
        ]
    },
    {
        title: "司法拍卖", //发布日期 标的类型 执行法院 拍品名称 起拍价 成交价格
        code: "05",
        form: [
            {
                label: "发布日期",
                key: "date"
            },
            {
                label: "label",
                value: "type"
            },
            {
                label: "执行法院",
                key: "court"
            },
            {
                label: "拍品名称",
                key: "name"
            },
            {
                label: "起拍价",
                key: "startPrice"
            },
            {
                label: "成交价格",
                key: "estPrice"
            }
        ]
    },
    {
        title: "股权出质", //登记日期 登记编号 出质人 质权人 出质股权数 出质状态
        code: "07",
        form: [
            {
                label: "登记日期",
                key: "date"
            },
            {
                label: "登记编号",
                key: "number"
            },
            {
                label: "出质人",
                key: "pledgor"
            },
            {
                label: "质权人",
                key: "pawnee"
            },
            {
                label: "出质股权数",
                key: "pledgorAmount"
            },
            {
                label: "出质状态",
                key: "status"
            }
        ]
    },
    {
        title: "知识产权出质", //登记日期 登记编号 出质人 质权人 状态 出质知识产权名称 出质知识产权编号
        code: "04",
        form: [
            {
                label: "登记日期",
                key: "publicDate"
            },
            {
                label: "登记编号",
                key: "seqNo"
            },
            {
                label: "出质人",
                key: "pledgor"
            },
            {
                label: "质权人",
                key: "pawnee"
            },
            {
                label: "状态",
                key: "status"
            },
            {
                label: "出质知识产权名称",
                key: "name"
            },
            {
                label: "出质知识产权编号",
                key: "number"
            }
        ]
    },
    {
        title: "动产抵押", //登记日期 登记编号 出质人 抵押权人 状态 抵押物名称
        code: "05",
        form: [
            {
                label: "登记日期",
                key: "date"
            },
            {
                label: "登记编号",
                key: "number"
            },
            {
                label: "出质人",
                key: "currency"
            },
            {
                label: "抵押权人",
                key: "mortgageesName"
            },
            {
                label: "状态",
                key: "status"
            },
            {
                label: "抵押物名称",
                key: "guaranteesName"
            }
        ]
    },
    {
        title: "税收违法", //直接责任财务人员 直接责任中介机构 案件性质 违法事实 法律依据及处罚 移送公安情况 所属税务机关 检查机关
        code: "03",
        form: [
            {
                label: "直接责任财务人员",
                key: "financialPeople"
            },
            {
                label: "直接责任中介机构",
                key: "agencyPeople"
            },
            {
                label: "案件性质",
                key: "caseType"
            },
            {
                label: "违法事实",
                key: "truth"
            },
            {
                label: "法律依据及处罚",
                key: "lawPunishment"
            },
            {
                label: "移送公安情况",
                key: "police"
            },
            {
                label: "所属税务机关",
                key: "pubDepartment"
            },
            {
                label: "检查机关",
                key: "checkDepartment"
            }
        ]
    },
    {
        title: "供应商", // 企业名称 统一社会信用代码 交易次数 交易总金额 最近一次交易信息时间
        code: "09",
        form: [
            {
                label: "企业名称",
                key: "ename"
            },
            {
                label: "统一社会信用代码",
                key: "creditCode"
            },
            {
                label: "交易次数",
                key: "dealNum"
            },
            {
                label: "交易总金额",
                key: "dealAmount"
            },
            {
                label: "最近一次交易信息时间",
                key: "lastDealDate"
            },
        ]
    },
    {
        title: "客户", // 交易次数 交易金额
        code: "10",
        form: [
            {
                label: "交易次数",
                key: "dealNum"
            },
            {
                label: "交易金额",
                key: "dealAmount",
                units: '(万元)'
            }
        ]
    },
    {
        title: "税务评级", // 评级年度 信用级别
        code: "01",
        form: [
            {
                label: "评级年度",
                key: "year"
            },
            {
                label: "信用级别",
                key: "year",
            }
        ]
    },
    {
        title: "招投标", // 项目名称 发布时间 项目金额 招标人名称
        code: "02",
        form: [
            {
                label: "项目名称",
                key: "title"
            },
            {
                label: "发布时间",
                key: "publishTime",
            },
            {
                label: "项目金额",
                key: "projectBudgetMoney",
            },
            {
                label: "招标人名称",
                key: "proprietorCompany",
            }
        ]
    },
    {
        title: "商标", // 商标名称 申请/注册号 申请日期 国际分类 公告日期 
        code: "01",
        form: [
            {
                label: "商标名称",
                key: "trademarkName"
            },
            {
                label: "申请/注册号",
                key: "regNumber",
            },
            {
                label: "申请日期",
                key: "applyDate",
            },
            {
                label: "国际分类",
                key: "typeNum",
            },
            {
                label: "公告日期",
                key: "applyDate",
            }
        ]
    },
    {
        title: "专利", // 专利名称 专利申请号 专利类型 法律状态 摘要
        code: "02",
        form: [
            {
                label: "专利名称",
                key: "patentName"
            },
            {
                label: "专利申请号",
                key: "requestNumStandard",
            },
            {
                label: "专利类型",
                key: "typeName",
            },
            {
                label: "法律状态",
                key: "lastStatus",
            },
            {
                label: "摘要",
                key: "brief",
            }
        ]
    },
    {
        title: "资质证书", // 证书名称 证书编号 证书状态 发证日期 到期日
        code: "05",
        form: [
            {
                label: "证书名称",
                key: "licenseName"
            },
            {
                label: "证书编号",
                key: "registerNo",
            },
            {
                label: "证书状态",
                key: "state",
            },
            {
                label: "发证日期",
                key: "validStart",
            },
            {
                label: "到期日",
                key: "validEnd",
            }
        ]
    },
    {
        title: "软件著作权", // 软件名称 登记号 登记日期 取得方式
        code: "03",
        form: [
            {
                label: "软件名称",
                key: "name"
            },
            {
                label: "登记号",
                key: "number",
            },
            {
                label: "登记日期",
                key: "approvalDate",
            },
            {
                label: "取得方式",
                key: "proprietorCompany",
            }
        ]
    },
    {
        title: "网站备案", // 域名 备案/许可证 审核日期
        code: "04",
        form: [
            {
                label: "域名",
                key: "domain"
            },
            {
                label: "备案/许可证",
                key: "bodyNumber",
            },
            {
                label: "审核日期",
                key: "checkDate",
            }
        ]
    },
    {
        title: "著作权", // 作品名称 创作完成日期 登记号 登记日期 作品类别
        code: "03",
        form: [
            {
                label: "作品名称",
                key: "shortName"
            },
            {
                label: "创作完成日期",
                key: "successDate",
            },
            {
                label: "登记号",
                key: "number",
            },
            {
                label: "登记日期",
                key: "approvalDate",
            },
            {
                label: "作品类别",
                key: "typeName",
            }
        ]
    },
    {
        title: "股权融资", // 融资时间 融资轮次 融资金额 投资方
        code: "01",
        form: [
            {
                label: "融资时间",
                key: "roundDate"
            },
            {
                label: "融资轮次",
                key: "round",
            },
            {
                label: "融资金额",
                key: "amount",
            },
            {
                label: "投资方",
                key: "investors",
            }
        ]
    }
]);

// 获取分页加载组件实例
const paging = ref(null);

// 页面标题
const pageTitle = ref();

// 数据总数
const totalCount = ref(0);

// 页面数据信息
const pageFormInfo = ref();

// 请求数据
const resData = ref([]);

// 请求Api
let API = null;

// 请求参数
const resParams = ref();

// 分页加载
const queryList = (pageNo, pageSize) => {
    console.log(pageNo, pageSize);
    let params = {
        ...resParams.value,
        pageNum: pageNo,
        pageSize: pageSize,
    }
    // setTimeout(()=>{
    API(params).then((res) => {
        if (res?.code == 200) {
            totalCount.value = res.total;
            res.rows.forEach((val)=>{
                if(pageTitle.value == '商标'){
                    val.typeNum = trademark.value[val.typeNum];
                }else if(pageTitle.value == '动产抵押'){
                    val.mortgagees && val.mortgagees.length ? val.mortgageesName = val.mortgagees.map(a => a.name).join(','):val.mortgageesName = '';
                    val.guarantees && val.guarantees.length ? val.guaranteesName = val.guarantees.map(a => a.name).join(','):val.guaranteesName = '';
                }
            })
            
            paging.value.complete(res.rows);
        }
    })
    // },100)
    
}
onLoad((options) => {
    // 获取传递的标题参数
    if (options) {
        const option = JSON.parse(decodeURIComponent(options.params));
        // 页面标题
        pageTitle.value = option.title;
        // 设置页面标题
        uni.setNavigationBarTitle({ title: pageTitle.value });
        // 匹配导航配置信息
        pageFormInfo.value = basicInfoNav.value.filter(a => a.title == pageTitle.value)[0];
        // 请求接口参数
        resParams.value = {
            creditcode: option.creditcode,
            companyname: option.companyname,
            category: pageFormInfo.value.code
        }
        const title_info = pageFormInfo.value.title;
        // 经营风险 type:1  经营信息 type:2
        if (option.type == 1) {
            API = title_info == '简易注销' ? title_info == '司法拍卖' ? legalrisklistApi : managelistApi : managerisklistApi;
            //股权质押角色（cagegory=07时，传2）
            if (resParams.category == '07') resParams.value.role = '2'; 
        } else if (option.type == 2) {
            API = managelistApi;
        }else if(option.type == 3){
            API = intelproplistApi;
            // 类型(P:著作权，S:软件著作权)
            pageTitle.value == '著作权' ? resParams.value.type = 'P' : pageTitle.value == '软件著作权' ? resParams.value.type = 'S' : '';
        }else if(option.type == 4){
            API = devhislistApi;
        }
    }
})
</script>

<style lang="scss" scoped>
.legal-risk-page {
    height: 100vh;
    box-sizing: border-box;
    background-color: #f5f5f5;
}


</style>
